package vip.xiaonuo.device.modular.service.impl;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import vip.xiaonuo.device.modular.entity.DevDict;
import vip.xiaonuo.device.modular.mapper.DevDictMapper;
import vip.xiaonuo.device.vo.Result;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 墨塵
 * @since 2023/5/17
 */
@Service("devDictService")
public class DevDictServiceImpl extends DeviceBaseService{

    @Resource
    private DevDictMapper devDictMapper;

    @Override
    protected Integer getReqType() {
        return null;
    }

    @Override
    protected Boolean getLogFlag() {
        return false;
    }

    @Override
    protected Result handle(JSONObject param) {
        String dictValue = param.getString("dictValue");
        if(StringUtils.isBlank(dictValue)){
            return Result.fail("参数缺失,请传入正确的参数值dictValue");
        }
        List<DevDict> list = devDictMapper.getList(dictValue);
        return Result.ok(list);
    }
}
